home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 27 / CU Amiga Magazine's Super CD-ROM 27 (1998)(EMAP Images)(GB)[!][issue 1998-10].iso / CUCD / Programming / Mesa / src-glut / glutCreateWindow.c < prev    next >
C/C++ Source or Header  |  1998-08-02  |  4KB  |  166 lines

  1. /*
  2.  * Amiga GLUT graphics library toolkit
  3.  * Version:  1.1
  4.  * Copyright (C) 1998 Jarno van der Linden
  5.  *
  6.  * This library is free software; you can redistribute it and/or
  7.  * modify it under the terms of the GNU Library General Public
  8.  * License as published by the Free Software Foundation; either
  9.  * version 2 of the License, or (at your option) any later version.
  10.  *
  11.  * This library is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.  * Library General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU Library General Public
  17.  * License along with this library; if not, write to the Free
  18.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  */
  20.  
  21.  
  22. /*
  23.  * glutCreateWindow.c
  24.  *
  25.  * Version 1.0  27 Jun 1998
  26.  * by Jarno van der Linden
  27.  * jarno@kcbbs.gen.nz
  28.  *
  29.  * Version 1.1  02 Aug 1998
  30.  * by Jarno van der Linden
  31.  * jarno@kcbbs.gen.nz
  32.  *
  33.  * - Quantizer plugin support added
  34.  *
  35.  */
  36.  
  37.  
  38. #include <proto/intuition.h>
  39. #include <proto/gadtools.h>
  40.  
  41. #include <stdlib.h>
  42.  
  43. #include "glutstuff.h"
  44.  
  45.  
  46. extern VOID CloseWindowSafely(struct Window *win);
  47.  
  48. struct NewMenu defmenu[] = {
  49.     { NM_TITLE,    "Left Menu",    0, 0, 0, 0, },
  50.     { NM_TITLE,    "Middle Menu",    0, 0, 0, 0, },
  51.     { NM_TITLE,    "Right Menu",    0, 0, 0, 0, },
  52.     { NM_END,    NULL,            0, 0, 0, 0, }
  53. };
  54.  
  55.  
  56. int glutCreateWindow( const char *title)
  57. {
  58.     struct GlutWindow *gw;
  59.     struct Screen *screen;
  60.     WORD zoom[4];
  61.  
  62.     gw = calloc(1,sizeof(struct GlutWindow));
  63.     if(gw)
  64.     {
  65.         screen = LockPubScreen(glutstuff.pubscreenname);
  66.         zoom[0] = glutstuff.initposx;
  67.         zoom[1] = glutstuff.initposy;
  68.         zoom[2] = glutstuff.initwidth;
  69.         zoom[3] = glutstuff.initheight;
  70.         gw->window = OpenWindowTags(NULL,
  71.                 WA_Title,                title,
  72.                 WA_PubScreen,            screen,
  73.  
  74.                 WA_Left,                glutstuff.initposx,
  75.                 WA_Top,                    glutstuff.initposy,
  76.                 WA_Width,                glutstuff.initwidth,
  77.                 WA_Height,                glutstuff.initheight,
  78.                 WA_MinWidth,            32,
  79.                 WA_MinHeight,            32,
  80.                 WA_MaxWidth,            ~0,
  81.                 WA_MaxHeight,            ~0,
  82.  
  83.                 WA_NoCareRefresh,        TRUE,
  84.                 WA_Activate,            TRUE,
  85.  
  86.                 WA_CloseGadget,            TRUE,
  87.                 WA_DragBar,                TRUE,
  88.                 WA_SizeGadget,            TRUE,
  89.                 WA_DepthGadget,            TRUE,
  90.                 WA_Zoom,                zoom,
  91.  
  92.                 TAG_END);
  93.         UnlockPubScreen(NULL,screen);
  94.  
  95.         if(gw->window)
  96.         {
  97.             gw->window->UserPort = glutstuff.msgport;
  98.  
  99.             gw->context = AmigaMesaRTLCreateContext(gw->window,
  100.                                         AMRTL_RGBAMode,        glutstuff.rgba,
  101.                                         AMRTL_NumColours,    glutstuff.numcolours,
  102.                                         AMRTL_ColourBase,    glutstuff.colourbase,
  103.                                         AMRTL_Quantizer,    glutstuff.quantizer,
  104.                                         TAG_SKIP,            glutstuff.quantizerversion == -1 ? 2 : 0,
  105.                                         AMRTL_QuantizerVersion,    glutstuff.quantizerversion,
  106.                                         TAG_END);
  107.             if(gw->context)
  108.             {
  109.                 if(ModifyIDCMP(gw->window,IDCMP_CLOSEWINDOW | IDCMP_VANILLAKEY | IDCMP_RAWKEY | IDCMP_MENUPICK | IDCMP_MOUSEBUTTONS | IDCMP_INTUITICKS | IDCMP_CHANGEWINDOW))
  110.                 {
  111.                     gw->winid = stuffGetNewWinID();
  112.                     gw->window->UserData = (APTR)gw;
  113.  
  114.                     gw->vi = GetVisualInfo(gw->window->WScreen, TAG_END);
  115.  
  116.                     gw->menu = CreateMenus(defmenu, TAG_END);
  117.                     LayoutMenus(gw->menu, gw->vi, TAG_END);
  118.                     SetMenuStrip(gw->window, gw->menu);
  119.  
  120.                     gw->qualifiers = 0;
  121.                     gw->mousex = -1;
  122.                     gw->mousey = -1;
  123.  
  124.                     gw->winx = gw->wincurx = gw->window->LeftEdge;
  125.                     gw->winy = gw->wincury = gw->window->TopEdge;
  126.                     gw->winwidth = gw->wincurwidth = gw->window->Width;
  127.                     gw->winheight = gw->wincurheight = gw->window->Height;
  128.  
  129.                     stuffLinkInWin(gw);
  130.  
  131.                     if(glutstuff.depth)
  132.                         glEnable(GL_DEPTH_TEST);
  133.  
  134.                     gw->displayfunc = NULL;
  135.                     gw->keyboardfunc = NULL;
  136.                     gw->reshapefunc = NULL;
  137.                     gw->visibilityfunc = NULL;
  138.                     gw->specialfunc = NULL;
  139.                     gw->mousefunc = NULL;
  140.  
  141.                     gw->needreshape = FALSE;
  142.                     gw->needreshapegui = TRUE;
  143.                     gw->needposition = FALSE;
  144.                     gw->needpositiongui = TRUE;
  145.                     gw->needredisplay = TRUE;
  146.                     gw->needvisibility = TRUE;
  147.                     gw->visible = TRUE;
  148.                     gw->needleftmenu = TRUE;
  149.                     gw->needmiddlemenu = TRUE;
  150.                     gw->needrightmenu = TRUE;
  151.  
  152.                     return(gw->winid);
  153.                 }
  154.  
  155.                 AmigaMesaRTLDestroyContext(gw->context);
  156.             }
  157.  
  158.             CloseWindowSafely(gw->window);
  159.         }
  160.  
  161.         free(gw);
  162.     }
  163.  
  164.     return(0);
  165. }
  166.